# -*- coding: utf-8 -*- 
#
# Description:
#
#  Definiton
#
#
#
# Changes:
#
# 2012-01-10
# Initial Commit
#
#
# Copyright 2010-2012, WyDev Team.
# Author: Polo35 (polo35580@hotmail.fr)
#
# Licenced under Academic Free License version 3.0
# Review WyGui README & LICENSE files for further details.

nname: 80
n 80(None)[set_idle_callback(self.idle, self.busy, threshold)
return None
]:
	i: 0(t), 76()
	o: 

nname: 76
n 76(None)[]:
	i: 0(f)
	o: 80()

nname: 0
n 0(threshold)[self.eventhandler = ScreenSaverMenuEventHandler(self)
Menu.__init__(self, name, type=type, universe=None)
self._getitems_keywords = dict()
]:
	i: 
	o: 76(f), 80(t)

nname: 0
n 0(None)[self.eventhandler = ScreenSaverMenuEventHandler(self)
Menu.__init__(self, name, type=type, universe=None)
self._getitems_keywords = dict()
if not threshold:
	pass
set_idle_callback(self.idle, self.busy, threshold)
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb769676c>}
nname: 0
n 0(None)[pygui_globs['menustack'].on_idle = True
self.show(True)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb769652c>}
nname: 33
n 33(None)[self.hide()
pygui_globs['menustack'].on_idle = False
]:
	i: 3(), 26(), 32(AE)
	o: 

nname: 26
n 26(None)[]:
	i: 0(except)
	o: 33()

nname: 3
n 3(None)[pygui_globs['menustack'].get_navigator().force_preview = True
]:
	i: 0(try)
	o: 33()

nname: 0
n 0(None)[]:
	i: 
	o: 3(try), 26(except)

nname: 26
n 26(None)[except:
	pass
self.hide()
pygui_globs['menustack'].on_idle = False
]:
	i: 0()
	o: 

nname: 0
n 0(None)[try:
	pygui_globs['menustack'].get_navigator().force_preview = True
]:
	i: 
	o: 26()

nname: 0
n 0(None)[try:
	pygui_globs['menustack'].get_navigator().force_preview = True
except:
	pass
self.hide()
pygui_globs['menustack'].on_idle = False
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76965cc>}
nname: 0
n 0(None)[]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb769626c>}
nname: 6
n 6(None)[__doc__ = ' Generic Screen Saver Menu '
show_help_banner = False
def __init__(self, name='ScreenSaver', type='screensaver', threshold=None):
	self.eventhandler = ScreenSaverMenuEventHandler(self)
	Menu.__init__(self, name, type=type, universe=None)
	self._getitems_keywords = dict()
	if not threshold:
		pass
	set_idle_callback(self.idle, self.busy, threshold)
	return None

def idle(self):
	pygui_globs['menustack'].on_idle = True
	self.show(True)

def busy(self):
	try:
		pygui_globs['menustack'].get_navigator().force_preview = True
	except:
		pass
	self.hide()
	pygui_globs['menustack'].on_idle = False

def clear(self):
	pass

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb7695d8c>}
nname: 0
n 0(None)[return self.text
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7696aac>}
nname: 35
n 35(None)[self.text = text
def self._getitems_keywords['screensaver_text']():
	return self.text

]:
	i: 0(t), 31()
	o: 

nname: 31
n 31(None)[]:
	i: 0(f)
	o: 35()

nname: 0
n 0(text)[ScreenSaverMenu.__init__(self, type='text_screensaver', threshold=threshold)
]:
	i: 
	o: 31(f), 35(t)

nname: 0
n 0(None)[ScreenSaverMenu.__init__(self, type='text_screensaver', threshold=threshold)
if not text:
	pass
self.text = text
def self._getitems_keywords['screensaver_text']():
	return self.text

]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76962cc>}
nname: 6
n 6(None)[__doc__ = ' ScreenSaver to display an animated text (aka killer feature) '
def __init__(self, text=None, threshold=None):
	ScreenSaverMenu.__init__(self, type='text_screensaver', threshold=threshold)
	if not text:
		pass
	self.text = text
	def self._getitems_keywords['screensaver_text']():
		return self.text


]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb7695d8c>}
nname: 0
n 0(None)[return self.image
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb769d8cc>}
nname: 63
n 63(None)[return ''
]:
	i: 24(), 59()
	o: 

nname: 59
n 59(None)[]:
	i: 0(f)
	o: 63()

nname: 24
n 24(None)[]:
	i: 0(t)
	o: 63()

nname: 0
n 0(self.stack.get_player('audioplayer') is not None)[]:
	i: 
	o: 24(t), 59(f)

nname: 0
n 0(None)[if self.stack.get_player('audioplayer') is not None:
	pass
return ''
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb769db8c>}
nname: 63
n 63(None)[return ''
]:
	i: 24(), 59()
	o: 

nname: 59
n 59(None)[]:
	i: 0(f)
	o: 63()

nname: 24
n 24(None)[]:
	i: 0(t)
	o: 63()

nname: 0
n 0(self.stack.get_player('audioplayer') is not None)[]:
	i: 
	o: 24(t), 59(f)

nname: 0
n 0(None)[if self.stack.get_player('audioplayer') is not None:
	pass
return ''
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb769dc0c>}
nname: 35
n 35(None)[self.image = image
self.stack = pygui_globs['menustack']
def self._getitems_keywords['screensaver_image']():
	return self.image

self._getitems_keywords['title'] = self._get_title
def self._getitems_keywords['artist']():
	if self.stack.get_player('audioplayer') is not None:
		pass
	return ''

def self._getitems_keywords['album']():
	if self.stack.get_player('audioplayer') is not None:
		pass
	return ''

self._getitems_keywords['duration'] = self._get_audio_duration
]:
	i: 0(t), 31()
	o: 

nname: 31
n 31(None)[]:
	i: 0(f)
	o: 35()

nname: 0
n 0(image)[ScreenSaverMenu.__init__(self, type='image_screensaver', threshold=threshold)
]:
	i: 
	o: 31(f), 35(t)

nname: 0
n 0(None)[ScreenSaverMenu.__init__(self, type='image_screensaver', threshold=threshold)
if not image:
	pass
self.image = image
self.stack = pygui_globs['menustack']
def self._getitems_keywords['screensaver_image']():
	return self.image

self._getitems_keywords['title'] = self._get_title
def self._getitems_keywords['artist']():
	if self.stack.get_player('audioplayer') is not None:
		pass
	return ''

def self._getitems_keywords['album']():
	if self.stack.get_player('audioplayer') is not None:
		pass
	return ''

self._getitems_keywords['duration'] = self._get_audio_duration
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7696f2c>}
nname: 50
n 50(None)[return u''
]:
	i: 45(), 49()
	o: 

nname: 49
n 49(None)[]:
	i: 0(f)
	o: 50()

nname: 45
n 45(None)[return player['title']
]:
	i: 24(t), 35()
	o: 50()

nname: 35
n 35(None)[]:
	i: 24(f)
	o: 45()

nname: 24
n 24(player['title'])[]:
	i: 0(t)
	o: 35(f), 45(t)

nname: 0
n 0(player)[player = self.stack.get_player('audioplayer')
]:
	i: 
	o: 24(t), 49(f)

nname: 50
n 50(None)[return u''
]:
	i: 24(), 0(f)
	o: 

nname: 24
n 24(None)[if not player['title']:
	pass
return player['title']
]:
	i: 0(t)
	o: 50()

nname: 0
n 0(player)[player = self.stack.get_player('audioplayer')
]:
	i: 
	o: 24(t), 50(f)

nname: 0
n 0(None)[player = self.stack.get_player('audioplayer')
if player:
	if not player['title']:
		pass
	return player['title']
return u''
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7696fac>}
nname: 129
n 129(None)[return None
]:
	i: 120(), 124()
	o: 

nname: 124
n 124(None)[return ''
]:
	i: 63(f)
	o: 129()

nname: 120
n 120(None)[return seconds_to_mmss_utc(seconds)
]:
	i: 97(), 110()
	o: 129()

nname: 110
n 110(None)[]:
	i: 72(f)
	o: 120()

nname: 97
n 97(None)[]:
	i: 72(t)
	o: 120()

nname: 72
n 72(seconds >= 3600)[seconds = int(duration)
]:
	i: 63(t)
	o: 97(t), 110(f)

nname: 63
n 63(duration)[duration = None
]:
	i: 24(), 59()
	o: 72(t), 124(f)

nname: 59
n 59(None)[]:
	i: 0(f)
	o: 63()

nname: 24
n 24(None)[]:
	i: 0(t)
	o: 63()

nname: 0
n 0(self.stack.get_player('audioplayer') is not None)[]:
	i: 
	o: 24(t), 59(f)

nname: 129
n 129(None)[return None
]:
	i: 72(), 124()
	o: 

nname: 124
n 124(None)[return ''
]:
	i: 0(f)
	o: 129()

nname: 72
n 72(None)[seconds = int(duration)
if seconds >= 3600:
	pass
return seconds_to_mmss_utc(seconds)
]:
	i: 0(t)
	o: 129()

nname: 0
n 0(duration)[if self.stack.get_player('audioplayer') is not None:
	pass
duration = None
]:
	i: 
	o: 72(t), 124(f)

nname: 0
n 0(None)[if self.stack.get_player('audioplayer') is not None:
	pass
duration = None
if duration:
	seconds = int(duration)
	if seconds >= 3600:
		pass
	return seconds_to_mmss_utc(seconds)
else:
	return ''
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76965ac>}
nname: 62
n 62(None)[ScreenSaverMenu.idle(self)
self.refresh_metadata(*[''] * 3)
return None
]:
	i: 39(), 52()
	o: 

nname: 52
n 52(None)[self.type = 'image_screensaver'
]:
	i: 0(f)
	o: 62()

nname: 39
n 39(None)[self.type = 'image_screensaver_player'
]:
	i: 0(t)
	o: 62()

nname: 0
n 0(self.stack.get_player('audioplayer') is not None)[nav = self.stack.get_navigator()
]:
	i: 
	o: 39(t), 52(f)

nname: 0
n 0(None)[nav = self.stack.get_navigator()
if self.stack.get_player('audioplayer') is not None:
	self.type = 'image_screensaver_player'
else:
	self.type = 'image_screensaver'
ScreenSaverMenu.idle(self)
self.refresh_metadata(*[''] * 3)
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb769680c>}
nname: 0
n 0(None)[louie_send('title', sender=self, value=title)
louie_send('artist', sender=self, value=artist)
louie_send('album', sender=self, value=album)
louie_send('duration', sender=self, value=self['duration'])
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb769644c>}
nname: 6
n 6(None)[__doc__ = ' ScreenSaver to display an animated image '
def __init__(self, image=None, threshold=None):
	ScreenSaverMenu.__init__(self, type='image_screensaver', threshold=threshold)
	if not image:
		pass
	self.image = image
	self.stack = pygui_globs['menustack']
	def self._getitems_keywords['screensaver_image']():
		return self.image

	self._getitems_keywords['title'] = self._get_title
	def self._getitems_keywords['artist']():
		if self.stack.get_player('audioplayer') is not None:
			pass
		return ''

	def self._getitems_keywords['album']():
		if self.stack.get_player('audioplayer') is not None:
			pass
		return ''

	self._getitems_keywords['duration'] = self._get_audio_duration

def _get_title(self):
	player = self.stack.get_player('audioplayer')
	if player:
		if not player['title']:
			pass
		return player['title']
	return u''

def _get_audio_duration(self):
	if self.stack.get_player('audioplayer') is not None:
		pass
	duration = None
	if duration:
		seconds = int(duration)
		if seconds >= 3600:
			pass
		return seconds_to_mmss_utc(seconds)
	else:
		return ''
	return None

def idle(self):
	nav = self.stack.get_navigator()
	if self.stack.get_player('audioplayer') is not None:
		self.type = 'image_screensaver_player'
	else:
		self.type = 'image_screensaver'
	ScreenSaverMenu.idle(self)
	self.refresh_metadata(*[''] * 3)
	return None

def refresh_metadata(self, title, artist, album):
	louie_send('title', sender=self, value=title)
	louie_send('artist', sender=self, value=artist)
	louie_send('album', sender=self, value=album)
	louie_send('duration', sender=self, value=self['duration'])

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb7695eec>}
nname: 0
n 0(None)[from __future__ import absolute_import
__all__ = ['ScreenSaverMenu', 'ImageScreenSaverMenu']
import os
from pygui.menu.menu import Menu
from pygui.menu.players.core import WPlayer
from pygui.item.mediaitem import MediaItem
from pygui.eventmanager.menus.screensaver import ScreenSaverMenuEventHandler
from pygui.shared import pygui_globs
from peewee.debug import DEBUG, GET_LOGGER, PRINT_EXCEPTION
from peewee.formatters import seconds_to_hhmmss_utc, seconds_to_mmss_utc
from peewee.messages import send as louie_send
from peewee.notifier import set_idle_callback
from peewee.notifier import Task
log = GET_LOGGER(__name__)
class ScreenSaverMenu(Menu):
	__doc__ = ' Generic Screen Saver Menu '
	show_help_banner = False
	def __init__(self, name='ScreenSaver', type='screensaver', threshold=None):
		self.eventhandler = ScreenSaverMenuEventHandler(self)
		Menu.__init__(self, name, type=type, universe=None)
		self._getitems_keywords = dict()
		if not threshold:
			pass
		set_idle_callback(self.idle, self.busy, threshold)
		return None

	def idle(self):
		pygui_globs['menustack'].on_idle = True
		self.show(True)

	def busy(self):
		try:
			pygui_globs['menustack'].get_navigator().force_preview = True
		except:
			pass
		self.hide()
		pygui_globs['menustack'].on_idle = False

	def clear(self):
		pass



class TextScreenSaverMenu(ScreenSaverMenu):
	__doc__ = ' ScreenSaver to display an animated text (aka killer feature) '
	def __init__(self, text=None, threshold=None):
		ScreenSaverMenu.__init__(self, type='text_screensaver', threshold=threshold)
		if not text:
			pass
		self.text = text
		def self._getitems_keywords['screensaver_text']():
			return self.text




class ImageScreenSaverMenu(ScreenSaverMenu):
	__doc__ = ' ScreenSaver to display an animated image '
	def __init__(self, image=None, threshold=None):
		ScreenSaverMenu.__init__(self, type='image_screensaver', threshold=threshold)
		if not image:
			pass
		self.image = image
		self.stack = pygui_globs['menustack']
		def self._getitems_keywords['screensaver_image']():
			return self.image

		self._getitems_keywords['title'] = self._get_title
		def self._getitems_keywords['artist']():
			if self.stack.get_player('audioplayer') is not None:
				pass
			return ''

		def self._getitems_keywords['album']():
			if self.stack.get_player('audioplayer') is not None:
				pass
			return ''

		self._getitems_keywords['duration'] = self._get_audio_duration

	def _get_title(self):
		player = self.stack.get_player('audioplayer')
		if player:
			if not player['title']:
				pass
			return player['title']
		return u''

	def _get_audio_duration(self):
		if self.stack.get_player('audioplayer') is not None:
			pass
		duration = None
		if duration:
			seconds = int(duration)
			if seconds >= 3600:
				pass
			return seconds_to_mmss_utc(seconds)
		else:
			return ''
		return None

	def idle(self):
		nav = self.stack.get_navigator()
		if self.stack.get_player('audioplayer') is not None:
			self.type = 'image_screensaver_player'
		else:
			self.type = 'image_screensaver'
		ScreenSaverMenu.idle(self)
		self.refresh_metadata(*[''] * 3)
		return None

	def refresh_metadata(self, title, artist, album):
		louie_send('title', sender=self, value=title)
		louie_send('artist', sender=self, value=artist)
		louie_send('album', sender=self, value=album)
		louie_send('duration', sender=self, value=self['duration'])



screensaver_dict = {'text': TextScreenSaverMenu, 'image': ImageScreenSaverMenu}
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb768868c>}
from __future__ import absolute_import
__all__ = ['ScreenSaverMenu', 'ImageScreenSaverMenu']
import os
from pygui.menu.menu import Menu
from pygui.menu.players.core import WPlayer
from pygui.item.mediaitem import MediaItem
from pygui.eventmanager.menus.screensaver import ScreenSaverMenuEventHandler
from pygui.shared import pygui_globs
from peewee.debug import DEBUG, GET_LOGGER, PRINT_EXCEPTION
from peewee.formatters import seconds_to_hhmmss_utc, seconds_to_mmss_utc
from peewee.messages import send as louie_send
from peewee.notifier import set_idle_callback
from peewee.notifier import Task
log = GET_LOGGER(__name__)
class ScreenSaverMenu(Menu):
	__doc__ = ' Generic Screen Saver Menu '
	show_help_banner = False
	def __init__(self, name='ScreenSaver', type='screensaver', threshold=None):
		self.eventhandler = ScreenSaverMenuEventHandler(self)
		Menu.__init__(self, name, type=type, universe=None)
		self._getitems_keywords = dict()
		if not threshold:
			pass
		set_idle_callback(self.idle, self.busy, threshold)
		return None

	def idle(self):
		pygui_globs['menustack'].on_idle = True
		self.show(True)

	def busy(self):
		try:
			pygui_globs['menustack'].get_navigator().force_preview = True
		except:
			pass
		self.hide()
		pygui_globs['menustack'].on_idle = False

	def clear(self):
		pass



class TextScreenSaverMenu(ScreenSaverMenu):
	__doc__ = ' ScreenSaver to display an animated text (aka killer feature) '
	def __init__(self, text=None, threshold=None):
		ScreenSaverMenu.__init__(self, type='text_screensaver', threshold=threshold)
		if not text:
			pass
		self.text = text
		def self._getitems_keywords['screensaver_text']():
			return self.text




class ImageScreenSaverMenu(ScreenSaverMenu):
	__doc__ = ' ScreenSaver to display an animated image '
	def __init__(self, image=None, threshold=None):
		ScreenSaverMenu.__init__(self, type='image_screensaver', threshold=threshold)
		if not image:
			pass
		self.image = image
		self.stack = pygui_globs['menustack']
		def self._getitems_keywords['screensaver_image']():
			return self.image

		self._getitems_keywords['title'] = self._get_title
		def self._getitems_keywords['artist']():
			if self.stack.get_player('audioplayer') is not None:
				pass
			return ''

		def self._getitems_keywords['album']():
			if self.stack.get_player('audioplayer') is not None:
				pass
			return ''

		self._getitems_keywords['duration'] = self._get_audio_duration

	def _get_title(self):
		player = self.stack.get_player('audioplayer')
		if player:
			if not player['title']:
				pass
			return player['title']
		return u''

	def _get_audio_duration(self):
		if self.stack.get_player('audioplayer') is not None:
			pass
		duration = None
		if duration:
			seconds = int(duration)
			if seconds >= 3600:
				pass
			return seconds_to_mmss_utc(seconds)
		else:
			return ''
		return None

	def idle(self):
		nav = self.stack.get_navigator()
		if self.stack.get_player('audioplayer') is not None:
			self.type = 'image_screensaver_player'
		else:
			self.type = 'image_screensaver'
		ScreenSaverMenu.idle(self)
		self.refresh_metadata(*[''] * 3)
		return None

	def refresh_metadata(self, title, artist, album):
		louie_send('title', sender=self, value=title)
		louie_send('artist', sender=self, value=artist)
		louie_send('album', sender=self, value=album)
		louie_send('duration', sender=self, value=self['duration'])



screensaver_dict = {'text': TextScreenSaverMenu, 'image': ImageScreenSaverMenu}
